package com.devops.admin.graphql;

import com.devops.admin.model.DOSOracleAwrReport;
import com.devops.admin.model.TableResult;
import com.devops.admin.po.TimeRangePo;
import com.devops.admin.service.DOSOracleAwrReportService;
import com.devops.admin.vo.DOSPageVo;
import com.devops.common.annotation.DOSLog;
import com.devops.constant.DevOpsConstant;
import com.netflix.graphql.dgs.DgsComponent;
import com.netflix.graphql.dgs.DgsQuery;
import com.netflix.graphql.dgs.InputArgument;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * @author jxt
 * @Notes
 * @date 2023/12/11 10:10
 */
@DgsComponent
public class DOSOracleAwrReportFetcher {
    @Autowired
    DOSOracleAwrReportService dosOracleAwrReportService;

    @RequiresPermissions(DevOpsConstant.RoleCode.LOGIN_USER)
    @DOSLog(description = "查询最新几条oracle数据库awr报告")
    @DgsQuery
    public List<DOSOracleAwrReport> getAwrReport(@InputArgument int size) {
        return dosOracleAwrReportService.getLatestReport(size);
    }

    @RequiresPermissions(DevOpsConstant.RoleCode.LOGIN_USER)
    @DOSLog(description = "分页查询oracle数据库awr报告")
    @DgsQuery
    public TableResult<DOSOracleAwrReport> getAwrReportPage(@InputArgument DOSPageVo pageVo, @InputArgument TimeRangePo timeRangePo) {
        return dosOracleAwrReportService.getReportList(pageVo, timeRangePo);
    }
}
